//
//  OpenFlowViewController.m
//  HallView
//
//  Created by Lv Changye on 11-7-24.
//  Copyright 2011年 139me. All rights reserved.
//

#import "OpenFlowViewController.h"
#import "UIImageExtras.h"
#import "AFGetImageOperation.h"
#import "TouXiang.h"
@implementation OpenFlowViewController

- (id)initWithFrame:(CGRect)frame {
    self.viewDelegate=self;
    self.dataSource=self;
	if (self == [super initWithFrame:frame])
                 //CGRectMake(0, 0, frame.size.width, frame.size.height)]) 
    {
        loadImagesOperationQueue = [[NSOperationQueue alloc] init];
        
        //[self setNumberOfImages:7];
        
    }
	
	return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder{
    if ((self = [super initWithCoder:aDecoder])) {
        loadImagesOperationQueue = [[NSOperationQueue alloc] init];
       // self.viewDelegate=self;
        //self.dataSource=self;
        
    }
    return self;
}

- (void)dealloc
{
    [loadImagesOperationQueue release];
    [super dealloc];
}


- (UIImage *) defaultImage{
    return nil;
    return [UIImage imageNamed:@"桌面.png"];
}
#pragma mark - View lifecycle


- (void)imageDidLoad:(NSArray *)arguments {
    
	UIImage *loadedImage = (UIImage *)[arguments objectAtIndex:0];
	NSNumber *imageIndex = (NSNumber *)[arguments objectAtIndex:1];
	
	// Only resize our images if they are coming from Flickr (samples are already scaled).
	// Resize the image on the main thread (UIKit is not thread safe).
    
    loadedImage = [loadedImage cropCenterAndScaleImageToSize:CGSizeMake(340, 166)];
    
	[self setImage:loadedImage forIndex:[imageIndex intValue]];
}
- (void)openFlowView:(AFOpenFlowView *)openFlowView requestImageForIndex:(int)index {
	AFGetImageOperation *getImageOperation = [[AFGetImageOperation alloc] initWithIndex:index viewController:self];
    //getImageOperation.imageURL=[NSURL URLWithString:@"http://www.baidu.com/img/baidu_sylogo1.gif"];
	
	[loadImagesOperationQueue addOperation:getImageOperation];
	[getImageOperation release];
}

- (void)openFlowView:(AFOpenFlowView *)openFlowView selectionDidChange:(int)index {
	NSLog(@"Cover Flow selection did change to %d", index);

    [self addFacingPerson];

}
-(void)changBig{
   
    
    [UIView beginAnimations:@"as" context:nil];
    [UIView setAnimationDuration:3.0];
    selectedCoverView.frame=CGRectMake(300, 0, 700, 500);
    [UIView commitAnimations];
}


-(void)addFacingPerson{

  
    TouXiang *P1=[TouXiang initWithName:@"吕昌业" image:[UIImage imageNamed:@"吕昌业.png"] money:5000];
    P1.frame=CGRectMake(210, -20, 40, 60);
    
    TouXiang *P2=[TouXiang initWithName:@"孙瑞" image:[UIImage imageNamed:@"孙瑞.png"] money:7200];
    P2.frame=CGRectMake(290, -5, 40, 60);
    
    TouXiang *P3=[TouXiang initWithName:@"盛庆宏" image:[UIImage imageNamed:@"盛庆宏.png"] money:5000];
    P3.frame=CGRectMake(315, 70, 40, 60);
    
    TouXiang *P4=[TouXiang initWithName:@"张启蒙" image:[UIImage imageNamed:@"张启蒙.png"] money:7200];
    P4.frame=CGRectMake(270, 130, 40, 60);
    
    TouXiang *P5=[TouXiang initWithName:@"张皓" image:[UIImage imageNamed:@"张皓.png"] money:5000];
    P5.frame=CGRectMake(150, 130, 40, 60);
    
    TouXiang *P6=[TouXiang initWithName:@"张红" image:[UIImage imageNamed:@"张红.png"] money:7200];
    P6.frame=CGRectMake(30, 130, 40, 60);
    
    TouXiang *P7=[TouXiang initWithName:@"张静" image:[UIImage imageNamed:@"张静.png"] money:5000];
    P7.frame=CGRectMake(-15, 70, 40, 60);
    
    TouXiang *P8=[TouXiang initWithName:@"×××" image:[UIImage imageNamed:@"头像框.png"] money:7200];
    P8.frame=CGRectMake(5, -5, 40, 60);
    
    TouXiang *P9=[TouXiang initWithName:@"×××" image:[UIImage imageNamed:@"头像框.png"] money:7200];
    P9.frame=CGRectMake(90, -20, 40, 60);
    
    [selectedCoverView addSubview:P1];
    [selectedCoverView addSubview:P2];
    [selectedCoverView addSubview:P3];
    [selectedCoverView addSubview:P4];
    [selectedCoverView addSubview:P5];
    [selectedCoverView addSubview:P6];
    [selectedCoverView addSubview:P7];
    [selectedCoverView addSubview:P8];
    [selectedCoverView addSubview:P9];
    
}
@end
